﻿<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
	mc:Ignorable="d"
	xmlns:local="clr-namespace:TeamResourceManageAssist" 
    xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
	xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
	x:Class="TeamResourceManageAssist.ProjectInfoController"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
	xmlns:behaviors="clr-namespace:SharpGIS.Silverlight.Behaviors;assembly=SharpGIS.Silverlight.Behaviors"
	d:DesignWidth="800" d:DesignHeight="600">
    <UserControl.Resources>
        <local:ProjectItem x:Key="Project" StartDate="2010/5/6" EndDate="2010/5/6">
            <local:TaskItem ID="1"  task_name="a" start_time="2010/5/27" end_time="2010/5/30" type="1"/>
            <local:TaskItem ID="2"  task_name="b" start_time="2010/5/28" end_time="2010/5/30" type="1"/>
            <local:TaskItem ID="3"  task_name="c" start_time="2010/5/29" end_time="2010/5/30" type="1"/>
            <local:TaskItem ID="4"  task_name="d" start_time="2010/5/30" end_time="2010/5/30" type="1"/>
            <local:TaskItem ID="5"  task_name="e" start_time="2010/5/31" end_time="2010/5/31" type="2"/>
            <local:TaskItem ID="6"  task_name="f" start_time="2010/6/1" end_time="2010/6/10" type="2"/>
            <local:TaskItem ID="7"  task_name="g" start_time="2010/6/2" end_time="2010/6/10" type="2"/>
            <local:TaskItem ID="8"  task_name="h" start_time="2010/6/3" end_time="2010/6/10" type="3"/>
            <local:TaskItem ID="9"  task_name="i" start_time="2010/6/4" end_time="2010/6/10" type="2"/>
            <local:TaskItem ID="10" task_name="j" start_time="2010/6/5" end_time="2010/6/10" type="3"/>
            <local:TaskItem ID="11" task_name="k" start_time="2010/6/6" end_time="2010/6/10" type="1"/>
            <local:TaskItem ID="12" task_name="l" start_time="2010/6/7" end_time="2010/6/11" type="2"/>
        </local:ProjectItem>
        <local:TestConverter x:Key="TestConverter"/>
        <local:Date2StrConverter x:Key="Date2StrConverter"/>
        <local:Type2ImgConvert x:Key="Type2ImgConverter"/>
        <local:Type2ColorConverter x:Key="Type2ColorConverter"/>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" DataContext="{StaticResource Project}" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        
        <!--左边的datagrid-->
        <data:DataGrid x:Name="DataGrid1" ColumnHeaderHeight="58" ItemsSource="{Binding}" IsReadOnly="True" Margin="0,0,20,00"
		    VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
		    VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Visible"
		    SelectionMode="Single" AutoGenerateColumns="False" >
            <data:DataGrid.Columns>
                <data:DataGridTextColumn Header="ID" Binding="{Binding ID}" IsReadOnly="True"/>
                <data:DataGridTemplateColumn Header="类型" IsReadOnly="True" CanUserReorder="False">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Height="32">
                                <Image Source="{Binding type, Converter={StaticResource Type2ImgConverter}}"/>
                                <TextBlock Text="{Binding task_name}"/>
                            </StackPanel>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                <data:DataGridTextColumn Header="描述" Binding="{Binding description}" IsReadOnly="True" CanUserReorder="False"/>
                <data:DataGridTextColumn Header="开始日期" Binding="{Binding start_time, Converter={StaticResource Date2StrConverter}}" IsReadOnly="True" CanUserReorder="False"/>
                <data:DataGridTextColumn Header="终止日期" Binding="{Binding end_time, Converter={StaticResource Date2StrConverter}}" IsReadOnly="True" CanUserReorder="False"/>
            </data:DataGrid.Columns>
        </data:DataGrid>
        <!--滚动条-->
        <Rectangle Width="20" VerticalAlignment="Stretch" HorizontalAlignment="Right" Fill="#FFEDF1F4"/>
        <ScrollBar Orientation="Vertical" VerticalAlignment="Stretch" Width="20" HorizontalAlignment="Right" 
                   Margin="0,58,0,0" x:Name="ScrollBar1" ViewportSize="100" 
                   SmallChange="1" Maximum="16" Scroll="ScrollBar1_Scroll"/>
        <controls:GridSplitter HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="5" Grid.Column="1"/>
        <!--右面的滚动条-->
        <data:DataGrid x:Name="DataGrid2" Grid.Column="1" Margin="5,0,0,0" ColumnHeaderHeight="58" ItemsSource="{Binding}"
		VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Visible" AutoGenerateColumns="False">
            <data:DataGrid.Columns>
                <data:DataGridTemplateColumn  Header="时间" IsReadOnly="True" CanUserReorder="False">
                    <data:DataGridTemplateColumn.HeaderStyle>
                        <Style TargetType="dataPrimitives:DataGridColumnHeader">
                            <Setter Property="ContentTemplate">
                                <Setter.Value>
                                    <DataTemplate>
                                        <Grid HorizontalAlignment="Left">
                                            <local:DatePart ChartStartDate="{Binding Path=StartDate, Source={StaticResource Project}}" 
                                                            ChartEndDate="{Binding Path=EndDate, Source={StaticResource Project}}" 
                                                            HorizontalAlignment="Left"/>
                                        </Grid>
                                    </DataTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </data:DataGridTemplateColumn.HeaderStyle>
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid Margin="4,0,0,0" Height="32">
                                <local:GantSyleBar StartDate="{Binding start_time}" EndDate="{Binding end_time}" 
                                                   ChartStartDate="{Binding Path=StartDate, Source={StaticResource Project}}" 
                                                   ChartEndDate="{Binding Path=EndDate, Source={StaticResource Project}}" 
                                                   BarColor="{Binding Path=type, Converter={StaticResource Type2ColorConverter}}"
                                                   HorizontalAlignment="Left"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
            </data:DataGrid.Columns>
        </data:DataGrid>

    </Grid>
</UserControl>